home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / WINPROGS / WTJ208.ZIP / MILLER / CGWINDOW.H < prev   
C/C++ Source or Header  |  1993-04-11  |  6KB  |  180 lines

  1. //----------------------------------------------------------------------
  2. // File: CGWINDOW.H
  3. //----------------------------------------------------------------------
  4. #ifndef __CGWINDOW_H
  5.      #define __CGWINDOW_H
  6.  
  7. //----------------------------------------------------------------------
  8. // DEFINES
  9. // Purpose: Microsoft magin numbers for standard controls
  10. class names
  11. //----------------------------------------------------------------------
  12. #define BUTTONCLASS (0x80)
  13. #define EDITCLASS        (0x81)
  14. #define STATICCLASS (0x82)
  15. #define LISTBOXCLASS     (0x83)
  16. #define SCROLLBARCLASS   (0x84)
  17. #define COMBOBOXCLASS    (0x85)
  18.  
  19. #define MAXEDIT          (0)
  20.  
  21. #ifndef RC_INVOKED
  22.  
  23. //----------------------------------------------------------------------
  24. // STRUCTURE: DLGTEMPLATE
  25. // Purpose: Defines the contents of a dialog box resource
  26. //----------------------------------------------------------------------
  27. typedef struct {
  28.      LONG Style;
  29.      BYTE ItemCount;
  30.      int  X,
  31.           Y,
  32.           CX,
  33.           CY;
  34. } DLGTEMPLATE, *PDLGTEMPLATE, FAR *LPDLGTEMPLATE, NEAR
  35. *NPDLGTEMPLATE;
  36.  
  37. //----------------------------------------------------------------------
  38. // STRUCTURE: DLGHDR
  39. // Purpose: Contains a general description of the dialog box
  40. resource
  41. //----------------------------------------------------------------------
  42. typedef struct {
  43.      LONG Style;
  44.      BYTE ItemCount;
  45.      int  X,
  46.           Y,
  47.           CX,
  48.           CY;
  49.      char MenuName[256],
  50.           ClassName[256],
  51.           CaptionText[256];
  52. } DLGHDR, *PDLGHDR, FAR *LPDLGHDR, NEAR *NPDLGHDR;
  53.  
  54. //----------------------------------------------------------------------
  55. // STRUCTURE: DLGFONTHDR
  56. // Purpose: Contains information about the dialog's font
  57. //----------------------------------------------------------------------
  58. typedef struct {
  59.      short     PointSize;
  60.      char szTypeFace[LF_FACESIZE];
  61. } DLGFONTHDR, *PDLGFONTHDR, FAR *LPDLGFONTHDR, NEAR
  62. *NPDLGFONTHDR;
  63.  
  64. //----------------------------------------------------------------------
  65. // STRUCTURE: DLGITEMTEMPLATE
  66. // Purpose: Defines each control in a dialog resource
  67. //----------------------------------------------------------------------
  68. typedef struct {
  69.      int  X,
  70.           Y,
  71.           CX,
  72.           CY,
  73.           ID;
  74.      LONG Style;
  75.      char Class,
  76.           Text;
  77.      BYTE Info;
  78. } DLGITEMTEMPLATE, *PDLGITEMTEMPLATE, FAR *LPDLGITEMTEMPLATE,
  79. NEAR      *NPDLGITEMTEMPLATE;
  80.  
  81. //----------------------------------------------------------------------
  82. // STRUCTURE: DLGITEM
  83. // Purpose: Defines each control in a dialog resource
  84. //----------------------------------------------------------------------
  85. typedef struct {
  86.      int  X,
  87.           Y,
  88.           CX,
  89.           CY,
  90.           ID;
  91.      LONG Style;
  92.      char Class[256],
  93.           Text[256];
  94.      BYTE Info;
  95.      DWORD     Data;
  96. } DLGITEM, *PDLGITEM, FAR *LPDLGITEM, NEAR *NPDLGITEM;
  97.  
  98. //----------------------------------------------------------------------
  99. // TYPEDEF: PROCESSCONTROL
  100. // Purpose: Prototypes control build function
  101. //----------------------------------------------------------------------
  102. typedef PTWindowsObject (*PROCESSCONTROL)(PTWindowsObject,
  103. DLGITEM&);
  104.  
  105. //----------------------------------------------------------------------
  106. // Class: CGWindow
  107. //----------------------------------------------------------------------
  108. _CLASSDEF(CGWindow)
  109. class _EXPORT CGWindow : public TWindow {
  110.      private:
  111.           HFONT          hFont;
  112.           LPSTR          AResourceName;
  113.           int       nScaleX;
  114.           int       nScaleY;
  115.           RECT      Place;
  116.  
  117.      public:
  118.                     CGWindow(PTWindowsObject, LPSTR);
  119.      virtual        ~CGWindow();
  120.      virtual HFONT  CreateFont(LPSTR, int);
  121.      virtual LPSTR  GetClassName() { return "CGWindow"; }
  122.      virtual void   PreProcessControl(DLGITEM &);
  123.      virtual PTWindowsObject ProcessControl(DLGITEM &);
  124.      virtual void   PostProcessControl(PTWindowsObject,
  125. DLGITEM &);
  126.      virtual void   SetupWindow();
  127.      virtual void   WMSize(RTMessage) = [WM_FIRST +
  128. WM_SIZE];
  129. }; // C: CGWindow
  130.  
  131. //----------------------------------------------------------------------
  132. // Class: CGWindowRegister
  133. //----------------------------------------------------------------------
  134. _CLASSDEF(CGWindowRegister)
  135. class _EXPORT CGWindowRegister : public Sortable {
  136.      private:
  137.           Pchar               szClass;
  138.           PROCESSCONTROL BuildIt;
  139.  
  140.      public:
  141.                     CGWindowRegister(char *, PROCESSCONTROL
  142. = NULL);
  143.      virtual        ~CGWindowRegister();
  144.      PTWindowsObject     Build(PTWindowsObject that,
  145. DLGITEM& DlgItem)
  146.                          { return (*BuildIt)(that, DlgItem);
  147. }
  148.      virtual classType isA() const { return 0; }
  149.      virtual char _FAR *nameOf() const { return 0; }
  150.      virtual hashValueType hashValue() const { return 0; }
  151.      virtual int isEqual( const Object _FAR & _o) const
  152.           { return !strcmp(RCGWindowRegister(_o).szClass,
  153. szClass); }
  154.      virtual int isLessThan(const Object _FAR & _o) const
  155.      {return strcmp(szClass, RCGWindowRegister(_o).szClass)
  156. < 0; }
  157.      virtual void printOn( ostream _FAR & ) const { ; }
  158. }; // C: CGWindowRegister
  159.  
  160. //----------------------------------------------------------------------
  161. // Functions
  162. //----------------------------------------------------------------------
  163. LPSTR GetDlgInfo(LPDLGTEMPLATE, PDLGHDR);
  164. LPSTR GetFontInfo(LPSTR, PDLGFONTHDR);
  165. LPSTR GetDlgItem(LPDLGITEMTEMPLATE, PDLGITEM);
  166. LPSTR MoveString(LPSTR, LPSTR, int);
  167. void SetControlFont(Pvoid, Pvoid);
  168.  
  169. PTWindowsObject BuildButton(PTWindowsObject, DLGITEM&);
  170. PTWindowsObject BuildEdit(PTWindowsObject, DLGITEM&);
  171. PTWindowsObject BuildStatic(PTWindowsObject, DLGITEM&);
  172. PTWindowsObject BuildListBox(PTWindowsObject, DLGITEM&);
  173. PTWindowsObject BuildScrollBar(PTWindowsObject, DLGITEM&);
  174. PTWindowsObject BuildComboBox(PTWindowsObject, DLGITEM&);
  175.  
  176. #endif // #ifndef RC_INVOKED
  177. #endif // #ifndef __CGWINDOW_H
  178.  
  179.  
  180.